cmake_minimum_required(VERSION 2.8)
add_compile_options(-std=c++11 -O3 -fstack-protector-all -Wl,-z,relro,-z,noexecstack -fPIC)
project(MediaCodec)

if(READFILE_MODE)
    add_definitions(-DMC_READFILE)
endif()

# ddk
find_package(DDK REQUIRED)
include_directories(${DDK_INCLUDE_DIRS} ${DDK_CEREAL_INCLUDE_DIRS} ${DDK_PROTOBUF_INCLUDE_DIRS} ${DDK_GFLAGS_INCLUDE_DIRS} ${DDK_OPENCV_INCLUDE_DIRS})

if(NOT DEFINED FFMPEG_PATH)
    message(FATAL_ERROR "please use -DFFMPEG_PATH=<>")
endif()
set(FFMPEG_DIR ${FFMPEG_PATH} CACHE INTERNAL "FFMPEG location")
link_directories(${FFMPEG_DIR}/lib)

# common
include_directories(. ../common/ ./src_engine/ ./dest_engine ${FFMPEG_DIR}/include)

# build for host
# main
file(GLOB_RECURSE SRC ./*.cpp ../common/*.cpp)
add_executable(MediaCodec ${SRC})
target_link_libraries(MediaCodec ${DDK_HOST_LIBRARIES} pthread avcodec avdevice avfilter avformat avutil swscale)